<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<Script Language="JavaScript">  
function isNumber(data, type)
{    
	var numStr=type;
	var thisChar;
	var counter=0;
	for(var i=0; i < data.length; i++)
		{
			thisChar=data.substring(i,i+1);
			if(numStr.indexOf(thisChar)!=-1)
			{counter++;}
		}
		if(counter==data.length)
		{return true;}
		else
		return false;
 }



function validate()
{
   // var ob = this.document.aapfrm;
   if(document.appfrm.username.value =="")
   {
     alert("Enter the valid User Name");
     document.appfrm.username.select();
     return false;
   }
   if(isNumber(document.appfrm.username.value, "0123456789  abcdefghijklmnopqrstuvwxyz  ABCDEFGHIJKLMNOPQRSTUVWXYZ")!=true)
   {
       alert("User Name can accept alphabet and numbers only");
       document.appfrm.username.select();
       return false;
   }
   
   if(document.appfrm.fname.value =="")
   {
     alert("Enter your First Name.");
     document.appfrm.fname.select();
     return false;
   }
   if(isNumber(document.appfrm.fname.value, "abcdefghijklmnopqrstuvwxyz  ABCDEFGHIJKLMNOPQRSTUVWXYZ")!=true)
   {
       alert("First Name field can accept alphabet only");
       document.appfrm.fname.select();
       return false;
   }
   if(document.appfrm.lname.value =="")
   {
    alert("Enter your Last Name.");
    document.appfrm.lname.select();
    return false;
   }
   if(isNumber(document.appfrm.lname.value, "abcdefghijklmnopqrstuvwxyz  ABCDEFGHIJKLMNOPQRSTUVWXYZ")!=true)
   {
       alert("Last Name field can accept alphabet only");
       document.appfrm.lname.select();
       return false;
   }
   if (document.appfrm.add1.value == "")
  {
    alert("Please enter the \"address\" ");
    document.appfrm.add1.select();
    return (false);
  }
  
  if (document.appfrm.add1.value.length >100)
  {
    alert("Please enter at most 50 characters in the \"address\" field.");
    document.appfrm.add1.select();
    return (false);
  }
  if (document.appfrm.add2.value.length >100)
  {
    alert("Please enter at most 50 characters in the \"address\" field.");
    document.appfrm.add2.select();
    return (false);
  }
  if (document.appfrm.add3.value.length >100)
  {
    alert("Please enter at most 50 characters in the \"address\" field.");
    document.appfrm.add3.select();
    return (false);
  }
  
   if(document.appfrm.phno.value =="")
   {
     alert("please enter the phone no");
     document.appfrm.phno.select();
     return false;
   }
   if(isNumber(document.appfrm.phno.value, "0123456789")!=true)
   {
       alert("Please enter only digits for phone no");
       document.appfrm.phno.select();
       return false;
   }
   if (document.appfrm.phno.value.length<11)
   {
     alert("Please enter 11 digit phone number including std code");
     document.appfrm.mob.select();
     return false;
   }
      if (document.appfrm.phno.value.length>11)
   {
     alert("Please enter 11 digit phone number including std code");
     document.appfrm.mob.select();
     return false;
   }
   if(document.appfrm.mob.value =="")
   {
     alert("Please enter the Mobile no");
     document.appfrm.mob.select();
     return false;
   }
   
   if(isNumber(document.appfrm.mob.value, "0123456789")!=true)
   {
       alert("Please enter only digits for mobile no");
       document.appfrm.mob.select();
       return false;
   }
   if (document.appfrm.mob.value.length<10)
  {
    alert("Please enter 10 digit mobile no");
    document.appfrm.mob.select();
    return false;
  }
     if (document.appfrm.mob.value.length>10)
  {
    alert("Please enter 10 digit mobile no");
    document.appfrm.mob.select();
    return false;
  }

  if(document.appfrm.usertitle.value =="")
   {
     alert("Enter the valid User title");
     document.appfrm.usertitle.select();
     return false;
   }
   if(isNumber(document.appfrm.usertitle.value, "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ")!=true)
   {
       alert("user title field can accept alphabet only");
       document.appfrm.usertitle.select();
       return false;
   }
   if(document.appfrm.edu.value =="")
   {
     alert("Enter the valid Education");
     document.appfrm.edu.select();
     return false;
   }
   if(isNumber(document.appfrm.edu.value, "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ")!=true)
   {
       alert("Education field can accept alphabet only");
       document.appfrm.edu.select();
       return false;
   }
   if(document.appfrm.license.value =="")
   {
     alert("Enter the valid licence type");
     document.appfrm.license.select();
     return false;
   }
   if(isNumber(document.appfrm.license.value, "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ")!=true)
   {
       alert("Licence field can accept alphabets only");
       document.appfrm.license.select();
       return false;
   }
   if(document.appfrm.validupto.value =="")
   {
     alert("Enter the valid date");
     document.appfrm.license.select();
     return false;
   }
   
}   

</Script>  
</body>
</html>